<?php


namespace App\Http\Controllers\Admin;

use App\DTOS\Admin\RoleUpgradeDTO;
use App\Exceptions\ServiceException;
use App\Http\Controllers\Controller;
use App\Services\Game\RoleUpgradeService;
use App\Utils\ResponseUtil;

class RoleUpgradeController extends Controller
{
    private RoleUpgradeService $RoleUpgradeService;

    /**
     * RoleUpgradeController constructor.
     * @param RoleUpgradeService $RoleUpgradeService
     */
    public function __construct(RoleUpgradeService $RoleUpgradeService)
    {
        $this->RoleUpgradeService = $RoleUpgradeService;
    }

    public function paginate()
    {
        try {
            $searchData = request()->all();
            $DTO = new RoleUpgradeDTO($searchData);
            $pagination = $this->RoleUpgradeService->paginate($DTO);
            $data = $pagination->items();
            $res =[];
            $res['code'] = 0;
            $res['data'] = $data;
            $res['count'] = $pagination->total();
            return ResponseUtil::json($res);
        }catch (ServiceException $e){
            return ResponseUtil::error($e->getMessage());
        }
    }

}
